#文档: https://www.runoob.com/python3/python3-built-in-functions.html

# 内置函数map
# def test(item):
#     print(item)
#     return 1
#
# result = map(test,[1,2,3,4,5])
# print(list(result))

# 将列表中的每个数字平方后返回
#对列表进行共性操作!!
# result = list(map(lambda x : x**2, [1,2,3,4,5]))
# print(result)

result = list(map(lambda x : x+1, [1,2,3,4,5]))
print(result)


# 内置函数filter
alphabets = ['a', 'b', 'd', 'e', 'i', 'j', 'o']
def filterVowels(alphabet):
    vowels = ['a', 'e', 'i', 'o', 'u']
    if(alphabet in vowels):
        return True
    else:
        return False
# filteredVowels 存每一次filterVowels返回True时的alphabets在被轮询的元素
filteredVowels = filter(filterVowels, alphabets)
print(list(filteredVowels))


# 将列表中的所有奇数过滤出来
list_01 = [1,2,3,4,5,6,7,8,9]
result = filter(lambda x:x%2==1 ,list_01)
print(list(result))


# 匿名函数
# x = lambda a=2 : a + 10
# print(x(5))